﻿using iTextSharp.text;
using SdmxMl.Manager;
using SdmxMl.Structure;

namespace SdmxMl.Pdf
{
    /// <summary>/ PDF export of MSD </summary>
    public class pdfMsdGen : PdfArtefactGen
    {
        public pdfMsdGen(string docPath, SmManager smMgr, string artefactFullId, string lang) 
            : base(docPath, smMgr, SdmxArtefactType.MetadataStructureDefinitions, artefactFullId, lang)
        {
            MetadataStructureDefinitionType msd = targetArtefact as MetadataStructureDefinitionType;

            try
            {
                // MSD Attributes
                document.Add(new Paragraph("Metadata Structure Definition"));
                document.Add(new Chunk(" "));
                document.Add(pdfVar.GetDetailArtefactTable(msd));
                document.Add(new Chunk(" "));

                // Target Identifiers
                pdfVar.GetDetailMsdTarget(document, msd.TargetIdentifiers);
                document.Add(new Chunk(" "));

                // Each Report
                foreach (ReportStructureType report in msd.ReportStructureList)
                    pdfVar.GetDetailMsdReport(document, report);
            }
            finally
            {
                document.Close();
            }

        }

    }
}
